/* chat.css - 优化版 */

/* 基础样式 */
body {
    background-color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

/* 聊天区域样式 */
.chat-box {
    height: 500px;
    overflow-y: auto;
    padding: 15px;
}

.message {
    padding: 10px 15px;
    border-radius: 10px;
    max-width: 80%;
    word-break: break-word;
}

.user-message {
    background-color: #e3f2fd;
    margin-left: auto;
    text-align: right;
    border-radius: 15px 15px 0 15px;
}

.ai-message {
    background-color: #f5f5f5;
    margin-right: auto;
    border-radius: 15px 15px 15px 0;
}

.message-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.message:hover .message-footer {
    opacity: 1;
}

.message-actions i {
    cursor: pointer;
    margin-left: 10px;
    font-size: 14px;
}

.liked {
    color: #4caf50;
}

.disliked {
    color: #f44336;
}

/* 思考中状态样式 */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--deepseek-secondary-text);
}

.thinking-indicator .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--deepseek-primary);
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

textarea {
    resize: none;
    min-height: 50px;
    max-height: 150px;
}

/* Markdown 样式 */
.ai-message h1,
.ai-message h2,
.ai-message h3,
.ai-message h4,
.ai-message h5,
.ai-message h6 {
    margin-top: 0.5em;
    margin-bottom: 0.5em;
}

.ai-message code {
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

.ai-message pre {
    background-color: #f6f8fa;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

.ai-message pre code {
    background: transparent;
    padding: 0;
}

.ai-message table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}

.ai-message th, .ai-message td {
    border: 1px solid #ddd;
    padding: 8px;
}

.ai-message th {
    background-color: #f2f2f2;
}

.ai-message blockquote {
    border-left: 3px solid #ddd;
    padding-left: 10px;
    color: #666;
}

/* DeepSeek 主题下的样式调整 */
.deepseek-message.thinking {
    opacity: 0.7;
}

/* 消息容器基础样式 */
.deepseek-message {
    position: relative; /* 确保相对定位 */
}

/* 消息操作按钮样式 */
.deepseek-message .message-actions {
    position: absolute;
    bottom: 8px; /* 位于底部 */
    left: 8px; /* 位于左侧 */
    display: flex;
    gap: 8px;
    padding: 4px;
    z-index: 10;
    /* 移除 visibility: hidden，确保按钮默认可见 */
}

/* 确保按钮自身可见 */
.deepseek-message .message-actions i {
    cursor: pointer;
    font-size: 14px;
    color: var(--deepseek-secondary-text, #6b7280);
    transition: all 0.2s;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    border: 1px solid var(--deepseek-border, #e5e7eb);
    opacity: 0.7; /* 默认半透明 */
}

/* 鼠标悬停效果 */
.deepseek-message .message-actions i:hover {
    color: var(--deepseek-primary, #2970ff);
    transform: scale(1.1);
    background-color: white;
    opacity: 1;
}

/* 确保AI消息有足够的下方padding */
.deepseek-message-ai {
    padding-bottom: 40px !important; /* 增加底部内边距，为按钮留出空间 */
}

/* 为用户消息也添加相同的样式 */
.deepseek-message-user {
    padding-bottom: 40px !important;
}

/* 调整时间戳样式 */
.deepseek-message .timestamp {
    color: var(--deepseek-secondary-text);
    font-size: 12px;
    margin-top: 4px;
    text-align: right;
}

/* 欢迎消息样式 */
.deepseek-welcome {
    text-align: center;
    padding: 40px 0;
    color: var(--deepseek-secondary-text);
}

.deepseek-welcome h2 {
    color: var(--deepseek-text);
    margin-bottom: 10px;
}

/* 已经存在的代码高亮样式调整 */
.deepseek-message pre {
    background-color: #f6f8fa;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
}

.deepseek-message pre code {
    background: transparent;
    padding: 0;
}

.deepseek-message code {
    background-color: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

/* 为 EventSource 直接连接方式调整样式 */
.deepseek-message .alert-danger {
    background-color: #fee2e2;
    color: #b91c1c;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #fecaca;
}

.deepseek-message.thinking .thinking-indicator {
    display: flex;
    align-items: center;
    color: var(--deepseek-secondary-text);
}

/* 错误消息样式 */
.deepseek-message .error-message {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 10px;
    margin-top: 8px;
}

/* 调整滚动行为 */
.deepseek-messages {
    scroll-behavior: smooth;
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* 确保聊天容器正确显示 */
.deepseek-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.deepseek-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    overflow: hidden;
}

.deepseek-chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--deepseek-border);
    font-weight: 600;
    position: relative;
    display: flex;
    align-items: center;
}

/* 修复版 - 按钮容器样式 */
.deepseek-input-actions {
    display: flex;
    align-items: center;
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 100;
    gap: 5px;
    height: 36px;
    transform: none !important;
}

/* 输入容器样式 */
.deepseek-input-container {
    position: relative;
    border: 1px solid var(--deepseek-border);
    border-radius: 8px;
    background-color: #ffffff;
    overflow: visible;
}

/* 输入框样式 */
.deepseek-textarea {
    width: 100%;
    min-height: 48px;
    max-height: 150px;
    padding: 12px 16px;
    padding-right: 90px;
    resize: none;
    border: none;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    overflow-y: auto;
}

/* 语音开关样式 */
.voice-toggle {
    display: flex;
    align-items: center;
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.voice-toggle span {
    margin-right: 8px;
    font-size: 14px;
    color: var(--deepseek-secondary-text);
}

/* 数字人开关样式 */
.avatar-toggle {
    display: flex;
    align-items: center;
    position: absolute;
    right: 140px; /* 增加与语音开关的距离 */
    top: 50%;
    transform: translateY(-50%);
}

.avatar-toggle span {
    margin-right: 8px;
    font-size: 14px;
    color: var(--deepseek-secondary-text);
}

/* 语音相关样式已移动到单独的文件中 */
/* 文件上传相关样式已移动到单独的文件中 */

/* Toast 通知样式 */
.toast {
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 8px;
    min-width: 200px;
}

.toast-header {
    background-color: transparent;
    border-bottom: none;
    color: #dc3545;
    padding: 0.5rem 1rem;
}

.toast-body {
    color: #6c757d;
    padding: 0.5rem 1rem;
    text-align: center;
}

/* 语音输入按钮样式 */
.deepseek-voice-input {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    width: 36px;
    height: 36px;
    color: var(--deepseek-secondary-text);
    border-radius: 50%;
    transition: all 0.2s;
}

.deepseek-voice-input:hover {
    background-color: rgba(33, 150, 243, 0.1);
    color: var(--deepseek-primary);
}

.deepseek-voice-input.active {
    color: #e53935;
    background-color: rgba(229, 57, 53, 0.1);
}

/* 语音输入指示器 */
.voice-input-indicator {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1000;
    width: 200px;
    border: 1px solid var(--deepseek-border);
}

.voice-wave {
    display: flex;
    justify-content: space-between;
    height: 40px;
    align-items: center;
    width: 80px;
    margin-bottom: 10px;
}

.voice-wave span {
    display: block;
    width: 3px;
    height: 10px;
    background-color: #2196F3;
    animation: wave 1.2s infinite ease-in-out;
}

.voice-wave span:nth-child(2) {
    animation-delay: 0.2s;
}

.voice-wave span:nth-child(3) {
    animation-delay: 0.4s;
}

.voice-wave span:nth-child(4) {
    animation-delay: 0.6s;
}

.voice-wave span:nth-child(5) {
    animation-delay: 0.8s;
}

@keyframes wave {
    0%, 40%, 100% {
        height: 10px;
    }
    20% {
        height: 30px;
    }
}

.voice-input-text {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}